﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;


namespace QLCHHoaLan
{
    public partial class FrmDonHangChuaGiao : Form
    {
        public FrmDonHangChuaGiao()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Menu main = new Menu();
            main.kq = 1;
            main.Show();
            this.Hide();
        }

        private void FrmDonHangChuaGiao_Load(object sender, EventArgs e)
        {
            DonHangChuaGiaoBUS dh = new DonHangChuaGiaoBUS();
            DataTable dt = dh.loadDonHang();
            dgvDonHangChuaGiao.DataSource = dt;
        }

        private void dgvDonHangChuaGiao_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int i = e.RowIndex;
            if (i >= 0)
            {
                string Ma = dgvDonHangChuaGiao.Rows[i].Cells[0].Value.ToString();
                txtMaHD.Text = Ma;
                txtNguoiDat.Text = dgvDonHangChuaGiao.Rows[i].Cells[1].Value.ToString();
                txtNguoiNhan.Text = dgvDonHangChuaGiao.Rows[i].Cells[3].Value.ToString();
                txtSDTNguoiNhan.Text = dgvDonHangChuaGiao.Rows[i].Cells[4].Value.ToString();
                txtDiaChiGiaoHang.Text = dgvDonHangChuaGiao.Rows[i].Cells[5].Value.ToString();
                txtThoiGianGiaoHang.Text = dgvDonHangChuaGiao.Rows[i].Cells[6].Value.ToString();
                txtTongTien.Text = dgvDonHangChuaGiao.Rows[i].Cells[9].Value.ToString();
            }
            else
            {
                return;
            }
            
        }

        private void btnGiaoHang_Click(object sender, EventArgs e)
        {
            DonHangChuaGiaoBUS dh = new DonHangChuaGiaoBUS();
            dh.Update_DonHang(Int32.Parse(txtMaHD.Text));
            DataTable dt = dh.loadDonHang();
            dgvDonHangChuaGiao.DataSource = dt;

        }
    }
}
